#include<functional>
#include<memory>
#include"tcp_server.hpp"
#include"daemon.hpp"
using namespace server;
void usage(const std::string proc)
{
    std::cout<<"Usage "<<proc<<" port"<<std::endl;
}
std::string echo(std::string message)
{
    return message;
}
int main(int argc,char*argv[])
{
    if(argc != 2)
    {
        usage(argv[1]);
        std::cout<<"port error"<<strerror(errno)<<std::endl;
        exit(USAGE_ERR);
    }
    u_int16_t port = atoi(argv[1]);
    std::shared_ptr<TcpServer> tcp = std::make_shared<TcpServer>(echo,port);
    tcp->InitServer();
    Daemon();
    tcp->start();
    return 0;
}